#ifndef __MODEL_HH__
#define __MODEL_HH__

#include <iostream>
using namespace std;

#include <QtCore/QTimer>
#include <QtGui/QTableView>

struct S {
public:	
  S();
  S(const char* name, int age, double weight, double height);
  
  char name[10];
  int age;
  double weight, height;
};

void load_data(S* d);

class STableModel : public QAbstractTableModel {
public:
  STableModel(size_t nof_rows, S* d);
  size_t nof_rows;
  S* rows;

  void grow();

  // Qt
  int rowCount(const QModelIndex&) const;
  int columnCount(const QModelIndex&) const;
  QVariant data(const QModelIndex& index, int role) const;
  QVariant headerData(int section, Qt::Orientation orientation,int role) const;
};

class RefreshTimer : public QTimer
{
  Q_OBJECT
  public:
  QTableView* t;
  STableModel* m;
  RefreshTimer(QObject* parent, QTableView* t, STableModel* m);

  public slots:
  void timeout();
};

#endif
